/**
 * Flixel Power Tools Test Suite
 * 
 * Test Selection Menu
 * 
 * @version 1.2 - April 5th 2011
 * @link http://www.photonstorm.com
 * @author Richard Davey / Photon Storm
*/

package  
{
	import org.flixel.*;
	import com.photonstorm.flixel.*;
	import tests.*;
	import flash.utils.getDefinitionByName;
	
	public class TestSuiteState extends FlxState
	{
		private var version:String = "- Test Suite v1.2 -";
		private var options:Array;
		private var header:TestsHeader;
		
		public function TestSuiteState()
		{
			super();
			
			options = new Array;
			
			options.push( { state: FlxVelocityTest1, color: [0x008000, 0x00FF00] } );
			options.push( { state: FlxVelocityTest2, color: [0x008000, 0x00FF00] } );
			options.push( { state: FlxVelocityTest3, color: [0x008000, 0x00FF00] } );
			
			options.push( { spacer: true } );
			
			options.push( { state: FlxGradientTest1, color: [0xFF8000, 0xDFDF00] } );
			options.push( { state: FlxGradientTest2, color: [0xFF8000, 0xDFDF00] } );
			options.push( { state: FlxGradientTest3, color: [0xFF8000, 0xDFDF00] } );
			
			options.push( { spacer: true } );
			
			options.push( { state: FlxBitmapFontTest1, color: [0x0080FF, 0x80FFFF] } );
			options.push( { state: FlxBitmapFontTest2, color: [0x0080FF, 0x80FFFF] } );
			
			options.push( { newColumn: true } );
			
			options.push( { state: FlxCollisionTest1, color: [0x2E2E2E, 0x606060] } );
			options.push( { state: FlxCollisionTest2, color: [0x2E2E2E, 0x606060] } );
			options.push( { state: FlxCollisionTest3, color: [0x2E2E2E, 0x606060] } );
			
			options.push( { spacer: true } );
			
			options.push( { state: FlxColorTest1, color: [0x8000FF, 0xBE7DFF] } );
			options.push( { state: FlxColorTest2, color: [0x8000FF, 0xBE7DFF] } );
			
			options.push( { spacer: true } );
			
			options.push( { state: FlxFlodTest1, color: [0xC0C0C0, 0x808080] } );
			
			options.push( { spacer: true } );
			
			options.push( { state: FlxDelayTest1, color: [0x6C3913, 0xC96923] } );
			
			options.push( { newColumn: true } );
			
			options.push( { state: FlxHealthBarTest1, color: [0xFF8000, 0xFF0080] } );
			options.push( { state: FlxHealthBarTest2, color: [0xFF8000, 0xFF0080] } );
			
			options.push( { spacer: true } );
			
			options.push( { state: FlxStarFieldTest1, color: [0x2FA41E, 0x266599] } );
			options.push( { state: FlxStarFieldTest2, color: [0x2FA41E, 0x266599] } );
		}
		
		override public function create():void
		{
			super.create();
			
			header = new TestsHeader(version, false);
			
			header.instructions.text = version;
			
			add(header);
			
			var xOffset:int = 16;
			var yOffset:int = 32;
			var currentY:int = yOffset;
			var padding:int = 2;
			
			for (var i:int = 0; i < options.length; i++)
			{
				var option:Object = options[i];
				
				if (option.newColumn)
				{
					xOffset += (80 + 16 + 8);
					currentY = yOffset;
				}
				else if (option.spacer)
				{
					currentY += 14;
				}
				else
				{
					var tempButton:FlxButtonPlus = new FlxButtonPlus(xOffset, currentY, startTest, [option.state], option.state.title, 80, 18);
					tempButton.updateInactiveButtonColors(option.color);
					tempButton.setMouseOverCallback(buttonOver, [option.state.description]);
					tempButton.setMouseOutCallback(buttonOut);
					
					add(tempButton);
					
					currentY += tempButton.height + padding;
				}
			}

			FlxG.mouse.show();
		}
		
		private function startTest(state:Class):void
		{
			FlxG.state = new state;
		}
		
		private function buttonOver(text:String):void
		{
			header.instructions.text = text;
		}
		
		private function buttonOut():void
		{
			header.instructions.text = "";
		}
		
	}

}